import { mkdirSync } from 'fs';
import { install, set } from 'husky';
import { join } from 'path';

export default function initHusky(projectRoot) {
  const path = join(projectRoot, '.husky');
  mkdirSync(path, { recursive: true });
  install(path);
  set(join(path, '/_/pre-commit'), 'npm run lint-staged');
  set(join(path, '/_/commit-msg'), 'npx --no-install commitlint --edit $1');
}
